import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import '../../foundation/style/normal_text_style.dart';
import '../container/radius_container.dart';
import '../text_field/public_text_field.dart';

/// FileName radius_text_view
///
/// @Author lax
/// @Date 2025/4/24
///
/// @Description

class RadiusTextView extends RadiusContainer {
  RadiusTextView({
    super.key,
    super.radius = 5,
    Color? borderColor,
    Color? color,
    Color? unableColor,
    String? text,
    String? hintText,
    bool enable = true,
    ValueChanged<String>? onChanged,
    TextStyle? style,
    TextStyle? unableStyle,
    TextStyle? hintStyle,
    TextStyle? counterStyle,
    EdgeInsets? padding =
        const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
    TextAlign? textAlign,
    TextInputType? keyboardType,
    List<TextInputFormatter>? inputFormatters,
    InputDecoration? decoration,
    int? maxLines = 5,
    int? minLines = 5,
    int? maxLength = 500,
  }) : super(
          alignment: Alignment.centerLeft,
          color: enable ? color : unableColor,
          padding: maxLength == null
              ? null
              : EdgeInsets.only(
                  bottom: padding?.bottom ?? 0,
                ),
          child: enable
              ? PublicTextField(
                  text: text,
                  hintText: hintText,
                  enable: enable,
                  onChanged: onChanged,
                  style: style,
                  unableStyle: unableStyle,
                  hintStyle: hintStyle,
                  counterStyle: counterStyle,
                  padding: maxLength == null
                      ? padding
                      : EdgeInsets.only(
                          left: padding?.left ?? 0,
                          right: padding?.right ?? 0,
                          top: padding?.top ?? 0,
                        ),
                  textAlign: textAlign,
                  keyboardType: keyboardType,
                  inputFormatters: inputFormatters,
                  decoration: decoration,
                  minLines: minLines,
                  maxLines: maxLines,
                  maxLength: maxLength,
                )
              : Padding(
                  padding: maxLength == null
                      ? (padding ?? EdgeInsets.zero)
                      : EdgeInsets.only(
                          left: padding?.left ?? 0,
                          right: padding?.right ?? 0,
                          top: padding?.top ?? 0,
                        ),
                  child: Text(text ?? '', style: NormalTextStyle()),
                ),
        );
}
